package sk.project.accounting.data.services;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import sk.project.accounting.data.dao.CompanyDao;
import sk.project.accounting.data.model.Company;

@Service
public class CompanyServiceImpl implements CompanyService{

	private static Logger log = Logger.getLogger(CompanyServiceImpl.class);
	
	@Autowired
	CompanyDao companyDao;
	
	@Transactional
	public List<Company> getAllCompanies() {
		log.info("Get all companies");	
		return companyDao.getAllCompanies();
	}

	@Transactional
	public Company findCompany(int id) {
		log.info("find company by id: " + id);
		return companyDao.getCompanyById(id);
	}

	@Transactional
	public int insertCompany(Company company) {
		log.info("Insert company: " + company.toString());
		int id = companyDao.addCompany(company);
		return id;
	}

}
